﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                    xmlns:Utils="clr-namespace:Patterns4Net.ArchitectureExplorer.Views.Utils" 
                    xmlns:Graph="clr-namespace:Patterns4Net.ArchitectureExplorer.ViewModels.Graph" 
                    mc:Ignorable="d">

    <Utils:EmptyOrNullToVisibilityConverter x:Key="EmptyOrNullToVisibilityConverter"/>
    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>

    <Color x:Key="ToggleButtonBorder">#FF223786</Color>   
    
	<Style x:Key="GroupHeading" TargetType="StackPanel">
		<Setter Property="Background" Value="#EEEEEEEE"/>
	</Style>
	
	<Style x:Key="GroupHeadingTitle" TargetType="TextBlock">		
	</Style>
	
	<Style x:Key="GroupItem" TargetType="TextBlock">
		<Setter Property="FontSize" Value="8"/>
		<Setter Property="Margin" Value="16,0,0,0"/>
	</Style>

    <Style x:Key="PlusOpener" TargetType="ToggleButton">										
		<Setter Property="Margin" Value="8,0,4,0"/>
		<Setter Property="VerticalAlignment" Value="Center"/>										
		<Style.Triggers>
			<Trigger Property="IsChecked" Value="False">
				<Setter Property="Template">
					<Setter.Value>
                        <ControlTemplate TargetType="ToggleButton">
							<Border BorderBrush="LightBlue"
								BorderThickness="1" 
								Width="10" 
								Height="10">
								<Border.Background>
									<SolidColorBrush Color="{DynamicResource {x:Static SystemColors.ControlLightColorKey}}"/>
								</Border.Background>
								<Canvas>
									<Line X1="4" Y1="1" X2="4" Y2="7" Stroke="Black"/> 
									<Line X1="1" Y1="4" X2="7" Y2="4" Stroke="Black"/> 
								</Canvas>
							</Border>													
						</ControlTemplate>
					</Setter.Value>
				</Setter>
			</Trigger>
			<Trigger Property="IsChecked" Value="True">
				<Setter Property="Template">
					<Setter.Value>
                        <ControlTemplate TargetType="ToggleButton">
							<Border BorderBrush="LightBlue"
								BorderThickness="1" 
								SnapsToDevicePixels="True"
								Width="10" 
								Height="10">
								<Border.Background>
									<SolidColorBrush Color="{DynamicResource {x:Static SystemColors.ControlLightColorKey}}"/>
								</Border.Background>
								<Canvas>
									<Line X1="1" Y1="4" X2="7" Y2="4" Stroke="Black"/> 
								</Canvas>
							</Border>													
						</ControlTemplate>
					</Setter.Value>
				</Setter>
			</Trigger>											
		</Style.Triggers>
	</Style>

    <Style x:Key="GraphicsToggleButton" TargetType="{x:Type ToggleButton}">
		<Style.Triggers>
			<Trigger Property="IsChecked" Value="False">
				<Setter Property="Template">
					<Setter.Value>
						<ControlTemplate>
							<Border Width="16" Height="15"
									Background="White"
									BorderThickness="1" 
									CornerRadius="3" 
									HorizontalAlignment="Center">
								<Border.BorderBrush>
									<SolidColorBrush Color="{DynamicResource ToggleButtonBorder}"/>
								</Border.BorderBrush>
								<Border.Effect>
		                			<DropShadowEffect BlurRadius="2" Color="LightGray" 
		                                    Opacity="0.3" Direction="315"/>
								</Border.Effect>
								<Canvas>
									<Path Data="M 2,2 L 7,7 L 12, 2" StrokeThickness="1">
										<Path.Stroke>
											<SolidColorBrush Color="{DynamicResource ToggleButtonBorder}"/>
										</Path.Stroke>
									</Path>
									<Path Data="M 2,6 L 7,11 L 12, 6" StrokeThickness="1">
										<Path.Stroke>
											<SolidColorBrush Color="{DynamicResource ToggleButtonBorder}"/>
										</Path.Stroke>										
									</Path>
								</Canvas>
							</Border>
						</ControlTemplate>				                    		              	
					</Setter.Value>               
				</Setter>
			</Trigger>
			<Trigger Property="IsChecked" Value="True">
				<Setter Property="Template">
					<Setter.Value>
						<ControlTemplate>
							<Border Width="16" Height="15"
									Background="White"
									BorderThickness="1" 
									CornerRadius="3" 
									HorizontalAlignment="Center">
								<Border.BorderBrush>
									<SolidColorBrush Color="{DynamicResource ToggleButtonBorder}"/>
								</Border.BorderBrush>
								<Border.Effect>
				                	<DropShadowEffect BlurRadius="2" Color="LightGray" 
				                                    Opacity="0.3" Direction="315"/>
								</Border.Effect>
								<Canvas>
									<Path Data="M 2,11 L 7,6 L 12, 11" StrokeThickness="1">
										<Path.Stroke>
											<SolidColorBrush Color="{DynamicResource ToggleButtonBorder}"/>
										</Path.Stroke>
									</Path>
									<Path Data="M 2,7 L 7,2 L 12, 7" StrokeThickness="1">
										<Path.Stroke>
											<SolidColorBrush Color="{DynamicResource ToggleButtonBorder}"/>
										</Path.Stroke>
									</Path>														
								</Canvas>
							</Border>
						</ControlTemplate>				                    		              	
					</Setter.Value>               
				</Setter>
			</Trigger>								
		</Style.Triggers>
	</Style>

    <DataTemplate DataType="{x:Type Graph:TypeInfoViewModel}" x:Key="TypeInfoTemplate">
        <Border BorderBrush="Black" x:Name="MainBorder"
				Background="White"
				BorderThickness="1"
				CornerRadius="7,7,7,7"
				Padding="0">
            <Border.Effect>
                <DropShadowEffect BlurRadius="4" Color="LightGray" 
                                    Opacity="0.3" Direction="315"/>
            </Border.Effect>		
			
			<StackPanel>
				<Border BorderBrush="Transparent"
						BorderThickness="0" Padding="0, 0, 0, 7"
						CornerRadius="7,7,0,0">
		            <Border.Background>
		                <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
		                    <GradientStop Offset="0" Color="{DynamicResource ToggleButtonBorder}" />
		                    <GradientStop Offset="1" Color="#FFFFFFFF" />
		                </LinearGradientBrush>
		            </Border.Background>	
					
					<StackPanel>	
	                	<Grid>
	                    	<Grid.ColumnDefinitions>
	            	        	<ColumnDefinition Width="Auto"/>
					        	<ColumnDefinition Width="30"/>
				        	</Grid.ColumnDefinitions>                            
	                                
	                    	<TextBlock 
                                Panel.ZIndex="1"
					        	Grid.Row="0" Grid.Column="0"
                                Foreground="Black"
					        	Text="{Binding Name}" 
					        	Margin="10, 10, 10, 8" FontSize="14.667" FontStyle="Italic" />

                            <ToggleButton Grid.Row="0" Grid.Column="1" x:Name="ShowContent"
								IsChecked="{Binding ShowExpanded}"
					        	HorizontalAlignment="Right" Margin="0,0,7,0" 
					        	Style="{DynamicResource GraphicsToggleButton}">
                            </ToggleButton>
                        </Grid>
                        <StackPanel Margin="30, 5, 0, 0">
                            <ItemsControl ItemsSource="{Binding Patterns}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Foreground="Black" Text="{Binding Name}"></TextBlock>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </StackPanel>
                    </StackPanel>
                </Border>
				
				<StackPanel x:Name="Content"
				 Visibility="{Binding IsChecked, ElementName=ShowContent, Converter={StaticResource BooleanToVisibilityConverter}}">				                    
                    
					<StackPanel x:Name="PropertiesGroup"
                        Visibility="{Binding Properties, Converter={StaticResource EmptyOrNullToVisibilityConverter}}">
                        
						<StackPanel Orientation="Horizontal" Style="{DynamicResource GroupHeading}">
                            <ToggleButton 
                                x:Name="ShowProperties"
                                Margin="8,0,4,0" 
								IsChecked="{Binding ShowExpanded, Mode=OneTime}"
                                Style="{DynamicResource PlusOpener}"/>	
							<TextBlock Style="{DynamicResource GroupHeadingTitle}">Properties</TextBlock>
						</StackPanel>
						
						 <ItemsControl 
                             Visibility="{Binding IsChecked, ElementName=ShowProperties, Converter={StaticResource BooleanToVisibilityConverter}}"
                             ItemsSource="{Binding Properties, Mode=OneWay}">
						 	<ItemsControl.ItemTemplate>
							 	<DataTemplate>
							 		<TextBlock 
										Text="{Binding Name}" 
										Style="{DynamicResource GroupItem}"/>
								</DataTemplate>
							</ItemsControl.ItemTemplate>
						 </ItemsControl>					
					</StackPanel>
					
					<StackPanel x:Name="MethodsGroup"
                        Visibility="{Binding Methods, Converter={StaticResource EmptyOrNullToVisibilityConverter}}">
						<StackPanel Orientation="Horizontal" Style="{DynamicResource GroupHeading}">
                            <ToggleButton 
                                x:Name="ShowMethods"
                                Margin="8,0,4,0" 
								IsChecked="{Binding ShowExpanded,Mode=OneTime}"
                                Style="{DynamicResource PlusOpener}"/>	
							<TextBlock Style="{DynamicResource GroupHeadingTitle}">Methods</TextBlock>
						</StackPanel>
						
						 <ItemsControl ItemsSource="{Binding Methods, Mode=OneWay}">
						 	<ItemsControl.ItemTemplate>
							 	<DataTemplate>
							 		<TextBlock 
                                        Visibility="{Binding IsChecked, ElementName=ShowMethods, Converter={StaticResource BooleanToVisibilityConverter}}"
										Text="{Binding .}" 
										Style="{DynamicResource GroupItem}"/>
								</DataTemplate>
							</ItemsControl.ItemTemplate>
						 </ItemsControl>					
					</StackPanel>				
				</StackPanel>
				
				<Border Height="4"
					Background="Transparent"
					BorderBrush="Transparent"/>								              
			</StackPanel>          
        </Border>
    </DataTemplate>     
    
</ResourceDictionary>